package day05;

import java.util.Random;

public class MethodDemo2 {
    public static void main(String[] args) {
        int num = sum(34, 45);
        System.out.println(num);
        num = sub(34, 78);
        System.out.println(num);
        double sum3 = sum2("sunshuangliang", 4.0);
        int[] df = generateArray();
        int s = 34;
        double[] bn = new double[s];
        bn = generateArray1(s);
        int dd=3,ff=99;
        int[]ern = generateArray2(dd,ff);
    }

    public static int sum(int num1, int num2) {
        int num = num1 + num2;
        return num;

    }

    public static int sub(int num1, int num2) {
        int sum = num1 + num2;
        return sum;

    }

    public static double sum2(String name, double c) {
        double sum = c * 2;
        System.out.println(name);
        return sum;

    }

    public static int[] generateArray() {
        int[] arr = new int[5];
        Random random = new Random();
        for (int i = 0; i < arr.length; i++) {
            arr[i] = random.nextInt(1000);
            System.out.println(arr[i]);

        }
        return arr;
    }

    public static double[] generateArray1(int num) {
        Random random = new Random();
        double[] arr = new double[num];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = random.nextDouble();
            System.out.println(arr[i]);
        }
        return arr;
    }
    public static int[] generateArray2(int length,int max) {
        Random random = new Random();
        int[] arr = new int[length];
        for (int i = 0; i < arr.length; i++) {
            arr[i] = random.nextInt(max+1);
            System.out.println(arr[i]);
        }
        return arr;
    }
}
/*
Random random =new Random();
int []arr=new int[length];
for(int i=0;i<arr.length;i++){
    arr[i]=random.NextInt(max+1);
        }


 */